/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : MoviePlayBack.c /Project:AVOS		       **
**        Revision : 1.1                                       	**
**                                                             	**
*****************************************************************/
#include "../menu.h"
#include "MoviePlayBackEvent.h"
#include "NetmenuSetupEvent.h"

INT32S WinMoviePlayBackMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return WinMoviePlayBackOnShow(hwnd, lpParam) ;
            
        case WM_KEYDOWN:
        	return WinMoviePlayBackOnKeyPress(hwnd, lpParam);
		default:
			break;
    }
    return 0 ;
}

void SetWinMoviePlayBackPalette(void)
{
    YUVENTRY mask_para[4] = {0,120,4095,4095};
    AWSetAlphaMask(1,4, mask_para);
    AWSetAlphaMask(2,4, mask_para);
    AWSetAlphaMask(3,4, mask_para);	
    YUVENTRY palette_para[16] = {0x8000 | 15208,0x8000 | 16216,0x8000 | 17880,0x8000 | 16392,16280,16184,16088,16040,16024,15880,15208,15720,15016,15064,15304,15144};
    AWSetPalette(1,16, palette_para);
    AWSetPalette(2,16, palette_para);
    AWSetPalette(3,16, palette_para);
    return ;
}

void SetWinMoviePlayBackPos(HWND* pControl, INT8U CurOsdSize)
{
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            RECT Draw576WindowRect = {0,0,720,576};
            pControl->winrect = Draw576WindowRect;
            CREATEWINDOWPARAM Draw576WindowPara = {3,{{100,488,512,32},
            {540,60,120,32},
            {100,410,512,70},
            {0,0,0,0}},
            {PF_PALETTE_256,PF_PALETTE_256,PF_PALETTE_256,0},SetWinMoviePlayBackPalette};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&Draw576WindowPara);
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            RECT VgaWindowRect = {0,0,1024,768};
            pControl->winrect = VgaWindowRect;
            CREATEWINDOWPARAM VgaWindowPara = {3,{{100,520,512,32},
            {540,60-WinStart_y,120,32},
            {100,440,512,70},
            {0,0,0,0}},
            {PF_PALETTE_256,PF_PALETTE_256,PF_PALETTE_256,0},SetWinMoviePlayBackPalette};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&VgaWindowPara);
            break ;
    #endif
            
	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:
            RECT NormalWindowRect = {0,0,720,480};
            pControl->winrect = NormalWindowRect;
            CREATEWINDOWPARAM NormalWindowPara = {3,{{100,418,512,32},
            {540,60,120,32},
            {100,346,512,70},
            {0,0,0,0}},
            {PF_PALETTE_256,PF_PALETTE_256,PF_PALETTE_256,0},SetWinMoviePlayBackPalette};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&NormalWindowPara);
            break ;

    }//end of switch
    return;
}

HWND *CreateControlWinMoviePlayBack(HWND* pParent,INT8U CurOsdSize)
{
    HWND* pNewControl;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            CREATEWINDOWPARAM Standardwindow_para = {3,{{100,488,512,32},
                          {540,60,120,32},
                          {100,410,512,70},
                          {0,0,0,0}},
                          {PF_PALETTE_256,PF_PALETTE_256,PF_PALETTE_256,0},SetWinMoviePlayBackPalette};
            //Create Menu Window -- 0
            pNewControl = AWCreateWinControl("TWindow","WinMoviePlayBack",WS_OVERLAPPEDWINDOW,
		                      0,0,0,0,NULL, (INT32S)&Standardwindow_para,WinMoviePlayBackMsgProc) ;
            pNewControl->win_id = 0 ;
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            CREATEWINDOWPARAM Vgawindow_para = {3,{{100,520,512,32},
                          {540,60-WinStart_y,120,32},
                          {100,440,512,70},
                          {0,0,0,0}},
                          {PF_PALETTE_256,PF_PALETTE_256,PF_PALETTE_256,0},SetWinMoviePlayBackPalette};
            //Create Menu Window -- 1
            pNewControl = AWCreateWinControl("TWindow","WinMoviePlayBack",WS_OVERLAPPEDWINDOW,
		                      0,0,0,0,NULL, (INT32S)&Vgawindow_para,WinMoviePlayBackMsgProc) ;
            pNewControl->win_id = 0 ;
            break ;
    #endif
            
	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:
            CREATEWINDOWPARAM Normalwindow_para = {3,{{100,418,512,32},
                          {540,60,120,32},
                          {100,346,512,70},
                          {0,0,0,0}},
                          {PF_PALETTE_256,PF_PALETTE_256,PF_PALETTE_256,0},SetWinMoviePlayBackPalette};
            //Create Menu Window -- 1
            pNewControl = AWCreateWinControl("TWindow","WinMoviePlayBack",WS_OVERLAPPEDWINDOW,
		                      0,0,0,0,NULL, (INT32S)&Normalwindow_para,WinMoviePlayBackMsgProc) ;
            pNewControl->win_id = 0 ;
            break ;
                        
    }//end of switch
            return pNewControl;
}

INT32S MoviePlayInfoBarMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
	switch( msg_type){
		case WM_SHOWWINDOW:
			return MoviePlayInfoBarOnShow(hwnd,lpParam);
		case WM_HIDEWINDOW:
			AWClearRectTxt(hwnd->winrect.left, hwnd->winrect.top, hwnd->winrect.width, hwnd->winrect.height) ;
			break;
		case WM_KEYDOWN:
			return MoviePlayInfoBarOnKeyPress(hwnd, lpParam) ;
					
		case WM_SECOND_TIMEOUT:
			return WinMoviePlayBackHide(hwnd, msg_type, lpParam);
	}
	
	return 0;		
}

void SetMoviePlayInfoBarPos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            pControl->winrect.top = pControl->parent->winrect.top + 488;
            pControl->winrect.left = pControl->parent->winrect.left + 100;
            pControl->winrect.width = 512;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 11;
            RECT Draw576DrawRect[11] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,512,32},
            {pControl->winrect.left + 20,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 70,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 120,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 170,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 220,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 270,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 320,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 370,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 406,pControl->winrect.top + 0,96,32},
            {pControl->winrect.left + 408,pControl->winrect.top + 8,96,32},
            };
            for(iLoop=0; iLoop < 11; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &Draw576DrawRect[iLoop], sizeof(RECT));
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            pControl->winrect.top = pControl->parent->winrect.top + 520;
            pControl->winrect.left = pControl->parent->winrect.left + 100;
            pControl->winrect.width = 512;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 11;
            RECT VgaDrawRect[11] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,512,32},
            {pControl->winrect.left + 20,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 70,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 120,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 170,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 220,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 270,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 320,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 370,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 406,pControl->winrect.top + 0,96,32},
            {pControl->winrect.left + 408,pControl->winrect.top + 8,96,32},
            };
            for(iLoop=0; iLoop < 11; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &VgaDrawRect[iLoop], sizeof(RECT));
            break ;
    #endif
            
	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:
            pControl->winrect.top = pControl->parent->winrect.top + 418;
            pControl->winrect.left = pControl->parent->winrect.left + 100;
            pControl->winrect.width = 512;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 11;
            RECT NormalDrawRect[11] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,512,32},
            {pControl->winrect.left + 20,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 70,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 120,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 170,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 220,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 270,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 320,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 370,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 406,pControl->winrect.top + 0,96,32},
            {pControl->winrect.left + 408,pControl->winrect.top + 8,96,32},
            };
            for(iLoop=0; iLoop < 11; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &NormalDrawRect[iLoop], sizeof(RECT));
            break ;

    }//end of switch
    return;
}

HWND *CreateControlMoviePlayInfoBar(HWND *pParent,INT8U CurOsdSize)
{
    //Create Control -- MoviePlayInfoBar
    HWND *pNewControl;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            pNewControl = AWCreateWinControl("TControl","MoviePlayInfoBar",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      100,488,512,32,pParent,0,MoviePlayInfoBarMsgProc) ;
            pNewControl->win_id = 1 ;
            pNewControl->draw_info_num = 11;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO Draw576DrawDatas[11] = {
                          {0,0,0,0,(INT32U)ICON_INFOBAR_STATUS512_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PREV_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_FB_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PLAY_FOCUS_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_FF_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_NEXT_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_STOP_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_ZOOM_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_SUB_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_PLAYTIME_BACKGROUND_2,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)infobar_time_str,DT_STRING_DATA}};            	

            memcpy(pNewControl->draw_info,Draw576DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            pNewControl = AWCreateWinControl("TControl","MoviePlayInfoBar",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      100,520,512,32,pParent,0,MoviePlayInfoBarMsgProc) ;
            pNewControl->win_id = 1 ;
            pNewControl->draw_info_num = 11;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO VgaDrawDatas[11] = {
                          {0,0,0,0,(INT32U)ICON_INFOBAR_STATUS512_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PREV_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_FB_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PLAY_FOCUS_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_FF_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_NEXT_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_STOP_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_ZOOM_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_SUB_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_PLAYTIME_BACKGROUND_2,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)infobar_time_str,DT_STRING_DATA}};            	

            memcpy(pNewControl->draw_info,VgaDrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;
    #endif
            
	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:
            pNewControl = AWCreateWinControl("TControl","MoviePlayInfoBar",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      100,418,512,32,pParent,0,MoviePlayInfoBarMsgProc) ;
            pNewControl->win_id = 1 ;
            pNewControl->draw_info_num = 11;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO NormalDrawDatas[11] = {
                          {0,0,0,0,(INT32U)ICON_INFOBAR_STATUS512_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PREV_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_FB_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PLAY_FOCUS_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_FF_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_NEXT_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_STOP_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_ZOOM_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_SUB_LOSE_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_INFOBAR_PLAYTIME_BACKGROUND_2,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)infobar_time_str,DT_STRING_DATA}};            	

            memcpy(pNewControl->draw_info,NormalDrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;

    }//end of switch
            return pNewControl;
}

INT32S MoviePlayStateMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_KEYDOWN:
        	return MoviePlayStateOnKeyPress(hwnd, lpParam);
		case WM_HIDEWINDOW:
			AWClearRectTxt(hwnd->winrect.left, hwnd->winrect.top, hwnd->winrect.width, hwnd->winrect.height) ;
			break;
		default:
			break;

    }
    return 0 ;
}

void SetMoviePlayStatePos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            pControl->winrect.top = pControl->parent->winrect.top + 60;
            pControl->winrect.left = pControl->parent->winrect.left + 540;
            pControl->winrect.width = 120;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 4;
            RECT Draw576DrawRect[4] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,120,32},
            {pControl->winrect.left + 32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 64,pControl->winrect.top + 0,10,32},
            {pControl->winrect.left + 74,pControl->winrect.top + 0,16,32},
            };
            for(iLoop=0; iLoop < 4; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &Draw576DrawRect[iLoop], sizeof(RECT));
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            pControl->winrect.top = pControl->parent->winrect.top + 60-WinStart_y;
            pControl->winrect.left = pControl->parent->winrect.left + 540;
            pControl->winrect.width = 120;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 4;
            RECT VgaDrawRect[4] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,120,32},
            {pControl->winrect.left + 32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 64,pControl->winrect.top + 0,10,32},
            {pControl->winrect.left + 74,pControl->winrect.top + 0,16,32},
            };
            for(iLoop=0; iLoop < 4; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &VgaDrawRect[iLoop], sizeof(RECT));
            break ;
    #endif

	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:
            pControl->winrect.top = pControl->parent->winrect.top + 60;
            pControl->winrect.left = pControl->parent->winrect.left + 540;
            pControl->winrect.width = 120;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 4;
            RECT NormalDrawRect[4] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,120,32},
            {pControl->winrect.left + 32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 64,pControl->winrect.top + 0,10,32},
            {pControl->winrect.left + 74,pControl->winrect.top + 0,16,32},
            };
            for(iLoop=0; iLoop < 4; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &NormalDrawRect[iLoop], sizeof(RECT));
            break ;

    }//end of switch
    return;
}

HWND *CreateControlMoviePlayState(HWND *pParent,INT8U CurOsdSize)
{
    //Create Control -- MoviePlayState
    HWND *pNewControl;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            pNewControl = AWCreateWinControl("TControl","MoviePlayState",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      540,60,120,32,pParent,0,MoviePlayStateMsgProc) ;
            pNewControl->win_id = 2 ;
            pNewControl->draw_info_num = 4;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO Draw576DrawDatas[4] = {
                          {0,0,120,32,(INT32U)ICON_INFOBAR_STATUS1,DT_RLE_BMP_DATA},
                          {0,0,32,32,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,10,32,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,16,32,(INT32U)0,DT_RLE_BMP_DATA}};
            memcpy(pNewControl->draw_info,Draw576DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;           

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            pNewControl = AWCreateWinControl("TControl","MoviePlayState",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      540,60-WinStart_y,120,32,pParent,0,MoviePlayStateMsgProc) ;
            pNewControl->win_id = 2 ;
            pNewControl->draw_info_num = 4;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO VgaDrawDatas[4] = {
                          {0,0,120,32,(INT32U)ICON_INFOBAR_STATUS1,DT_RLE_BMP_DATA},
                          {0,0,32,32,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,10,32,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,16,32,(INT32U)0,DT_RLE_BMP_DATA}};
            memcpy(pNewControl->draw_info,VgaDrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;       
    #endif

	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:   
            pNewControl = AWCreateWinControl("TControl","MoviePlayState",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      540,60,120,32,pParent,0,MoviePlayStateMsgProc) ;
            pNewControl->win_id = 2 ;
            pNewControl->draw_info_num = 4;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO NormalDrawDatas[4] = {
                          {0,0,120,32,(INT32U)ICON_INFOBAR_STATUS1,DT_RLE_BMP_DATA},
                          {0,0,32,32,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,10,32,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,16,32,(INT32U)0,DT_RLE_BMP_DATA}};
            memcpy(pNewControl->draw_info,NormalDrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;       
                        
    }//end of switch
            return pNewControl;
}

void SetAviSubCtrlPos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            pControl->winrect.top = pControl->parent->winrect.top + 410;
            pControl->winrect.left = pControl->parent->winrect.left + 100;
            pControl->winrect.width = 512;
            pControl->winrect.height = 70;
            pControl->draw_info_num = 3;
            RECT DrawRect576i[3] = {
	     {pControl->winrect.left + 0,pControl->winrect.top + 0,512,70},		
            {pControl->winrect.left + 0,pControl->winrect.top + 8,512,30},
            {pControl->winrect.left + 0,pControl->winrect.top + 38,512,30},
            };
            for(iLoop=0; iLoop < 3; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &DrawRect576i[iLoop], sizeof(RECT));
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            pControl->winrect.top = pControl->parent->winrect.top + 440;
            pControl->winrect.left = pControl->parent->winrect.left + 100;
            pControl->winrect.width = 512;
            pControl->winrect.height = 70;
            pControl->draw_info_num = 3;
            RECT VgaDrawRect[3] = {
	     {pControl->winrect.left + 0,pControl->winrect.top + 0,512,70},
            {pControl->winrect.left + 0,pControl->winrect.top + 8,512,30},
            {pControl->winrect.left + 0,pControl->winrect.top + 38,512,30},
            };
            for(iLoop=0; iLoop < 3; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &VgaDrawRect[iLoop], sizeof(RECT));
            break ;
    #endif
			
	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:
            pControl->winrect.top = pControl->parent->winrect.top + 346;
            pControl->winrect.left = pControl->parent->winrect.left + 100;
            pControl->winrect.width = 512;
            pControl->winrect.height = 70;
            pControl->draw_info_num = 3;
            RECT NormalDrawRect[3] = {
	     {pControl->winrect.left + 0,pControl->winrect.top + 0,512,70},
            {pControl->winrect.left + 0,pControl->winrect.top + 8,512,30},
            {pControl->winrect.left + 0,pControl->winrect.top + 38,512,30},
            };
            for(iLoop=0; iLoop < 3; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &NormalDrawRect[iLoop], sizeof(RECT));
            break ;

    }//end of switch
    return;
}

INT32S AviSubCtrlMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return AviSubCtrlOnShow(hwnd, lpParam) ;
	 case WM_HIDEWINDOW:
	     return AviSubCtrlOnHide(hwnd, lpParam) ;
    }
    return 0 ;
}

HWND *CreateControlAviSubCtrl(HWND *pParent,INT8U CurOsdSize)
{
    //Create Control -- AviSubCtrl
    HWND *pNewControl;
    switch(CurOsdSize){
	case OsdSize576i:
	case OsdSize576p:
	case OsdSize576iCVBS:
            pNewControl = AWCreateWinControl("TControl","AviSubCtrl",(WS_CHILDWINDOW | WS_DISVISIBLE),
		                      100,410,512,70,pParent,0,AviSubCtrlMsgProc) ;
            pNewControl->win_id = 3 ;
            pNewControl->draw_info_num = 3;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO Draw576DrawDatas[3] = {
			     {0,0,0,0,(INT32U)ICON_SUB_BLANK_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)sub_txt_line1,DT_STRING_DATA},
                          {0,0,0,0,(INT32U)sub_txt_line2,DT_STRING_DATA}};
            memcpy(pNewControl->draw_info,Draw576DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;

    #ifdef SUPPORT_VGA		
	case OsdSizeVga:
            pNewControl = AWCreateWinControl("TControl","AviSubCtrl",(WS_CHILDWINDOW | WS_DISVISIBLE),
		                      100,440,512,70,pParent,0,AviSubCtrlMsgProc) ;
            pNewControl->win_id = 3 ;
            pNewControl->draw_info_num = 3;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO VgaDrawDatas[3] = {
			     {0,0,0,0,(INT32U)ICON_SUB_BLANK_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)sub_txt_line1,DT_STRING_DATA},
                          {0,0,0,0,(INT32U)sub_txt_line2,DT_STRING_DATA}};
            memcpy(pNewControl->draw_info,VgaDrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;
    #endif
			
	case OsdSize480i:
	case OsdSize480p:
	case OsdSize480iCVBS:	
            pNewControl = AWCreateWinControl("TControl","AviSubCtrl",(WS_CHILDWINDOW | WS_DISVISIBLE),
		                      100,346,512,70,pParent,0,AviSubCtrlMsgProc) ;
            pNewControl->win_id = 3 ;
            pNewControl->draw_info_num = 3;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO NormalDrawDatas[3] = {
			     {0,0,0,0,(INT32U)ICON_SUB_BLANK_PLBK,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)sub_txt_line1,DT_STRING_DATA},
                          {0,0,0,0,(INT32U)sub_txt_line2,DT_STRING_DATA}};
            memcpy(pNewControl->draw_info,NormalDrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;

    }//end of switch
            return pNewControl;
}


HWND* CreateMenuWinMoviePlayBack(void)
{
    HWND *pNewControl ;
    TWINDOWS *pWin;
    HWND *pWinMoviePlayBack = CreateControlWinMoviePlayBack(NULL,CurrentOsdSize);
    SetWinMoviePlayBackPos(pWinMoviePlayBack,CurrentOsdSize);

    pNewControl= CreateControlMoviePlayInfoBar(pWinMoviePlayBack,CurrentOsdSize);
    SetMoviePlayInfoBarPos(pNewControl,CurrentOsdSize);

    pNewControl= CreateControlMoviePlayState(pWinMoviePlayBack,CurrentOsdSize);
    SetMoviePlayStatePos(pNewControl,CurrentOsdSize);

    pNewControl=CreateControlAviSubCtrl(pWinMoviePlayBack,CurrentOsdSize);
    SetAviSubCtrlPos(pNewControl,CurrentOsdSize);

    pWin = (TWINDOWS *)pWinMoviePlayBack;
    pWin->pFocusControl = AWFindWinCtrlByName("MoviePlayInfoBar");
    return pWinMoviePlayBack;
}

void WinResetWinMoviePlayBackControlsPos(HWND *pControl, INT8U CurOsdSize)
{
    switch(pControl->win_id){
        case 0://WinMoviePlayBack
            SetWinMoviePlayBackPos(pControl,CurOsdSize) ;
            break ;
        case 1://MoviePlayInfoBar
            SetMoviePlayInfoBarPos(pControl,CurOsdSize) ;
            break ;
        case 2://MoviePlayState
            SetMoviePlayStatePos(pControl,CurOsdSize) ;
            break ;
        case 3://AviSubCtrl
            SetAviSubCtrlPos(pControl,CurOsdSize) ;
            break ;
    }//end of switch
}

void WinResetWinMoviePlayBackPos(HWND *pControl, INT8U CurOsdSize)
{
    HWND *pChildControl;
    if(pControl == NULL)
        pControl = AWFindWinCtrlByName("WinMoviePlayBack");
    if(pControl == NULL) return ;

    WinResetWinMoviePlayBackControlsPos(pControl, CurOsdSize) ;
    pChildControl = pControl->children ;
    while(pChildControl != NULL){
    	WinResetWinMoviePlayBackPos(pChildControl, CurOsdSize) ;
    	pChildControl = pChildControl->siblings ;
	}
	return ;
}

